<h1>Unit Tests Results</h1>

<p class="p_pop_red">Tests failed: <?= $report['total_failed'] ?>, passed: <?= $report['total_passed'] ?></p>


<?php 
   $titles = array('Failed', 'Passed');
   $reports = array('failed_tests', 'passed_tests');

   
   /**
    * Prints two tables with unit test results: one with failed tests, one with passed tests
    */
   for($i = 0; $i < 2; $i++):
?>

<h2><?= $titles[$i] ?></h2>

<table class="test_results">
   <thead>
      <tr>
         <th>Test Name</th>
         <th>Message</th>
         <th>Status</th>
      </tr>
   </thead>
   
   <?php foreach($report[$reports[$i]] as $res):?>
      <tbody>
         <tr>
            <td><?= $res['Test Name'] ?></td>
            <td><?= $res['Notes'] ?></td>
            <td><?= $res['Result'] ?></td>
         </tr>

         <tr>
            <td colspan="3"><?= $res['File Name'] ?> on line <?= $res['Line Number'] ?></td>
         </tr>

      </tbody>
   <?php endforeach; ?>
   
</table>

<?php endfor; ?>